package com.iflytek.autofly.setting.biz.networking;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;

import com.iflytek.autofly.setting.biz.base.EditActivity;

/**
 * <b>Description: </b>TODO<br/>
 * <b>Change History:</b><br/>
 * <table border="1">
 * <tr>
 * <td><b>user</b></td>
 * <td><b>date</b></td>
 * <td><b>time</b></td>
 * <td><b>reason</b></td>
 * </tr>
 * <tr>
 * <td>JunLuan@iflytek.com</td>
 * <td>2015/12/2</td>
 * <td>14:50</td>
 * <td>创建此文件</td>
 * </tr>
 * </table>
 *
 * @author JunLuan@iflytek.com
 */
public class BtNameEditActivity extends EditActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mEditEt.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                int valueLength = 0;
                String chinese = "[\u4e00-\u9fa5]";
                for (int i = 0; i < s.length(); i++) {
                    String temp = s.subSequence(i, i + 1).toString();
                    if (temp.matches(chinese)) {
                        valueLength += 2;
                    } else {
                        valueLength++;
                    }
                }
                if (valueLength > 0 && valueLength <= 16) {
                    mSaveBtn.setEnabled(true);
                } else {
                    mSaveBtn.setEnabled(false);
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

    }
}
